var echarts = require("echarts");
var dayjs = require("dayjs");
import {
    fontChart,
    getpercentage
} from "@/views/monitoring/apiindex.js";
export default {
    data() {
        return {

        }
    },
    methods: {

        getprogress(list) {
            let value = list[0] || "0";
            let refs = list[1];
            let bgone = list[2];
            let totle = 100;
            echarts.init(this.$refs[refs]).dispose();
            let defaultAlarm_E = echarts.init(this.$refs[refs]);
            let obj = {
                title: {
                    text: value,
                    x: "center",
                    y: "32%",
                    textStyle: {
                        color: bgone,
                        fontSize: 22,
                        fontWeight: "normal",
                    },
                },
                tooltip: {
                    trigger: "item",
                },
                angleAxis: {
                    axisLine: {
                        show: false,
                    },
                    axisLabel: {
                        show: false,
                    },
                    splitLine: {
                        show: false,
                    },
                    axisTick: {
                        show: false,
                    },
                },
                radiusAxis: {
                    type: "category",
                    axisLine: {
                        show: false,
                    },
                    axisTick: {
                        show: false,
                    },
                    axisLabel: {
                        show: true,
                    },
                    data: [],
                },
                polar: {
                    radius: "110%",
                    center: ["50%", "40%"],
                },
                series: [
                    // 极坐标系下柱状图
                    // 实际值
                    {
                        type: "bar",
                        data: [value],
                        z: 1,
                        coordinateSystem: "polar",
                        barMaxWidth: 5,
                        roundCap: 1,
                        color: bgone,
                    },
                    // 背景图形
                    {
                        type: "bar",
                        data: [totle],
                        z: 0,
                        silent: true,
                        coordinateSystem: "polar",
                        barMaxWidth: 5,
                        roundCap: true,
                        color: "rgba(40,68,115,1)",
                        barGap: "-100%",
                    },
                ],
            };

            defaultAlarm_E.setOption(obj, true);
        },
        getexitStatistics() {
            echarts.init(this.$refs["exitStatistics"]).dispose();
            let defaultAlarm_E = echarts.init(this.$refs["exitStatistics"]);
            let xdata = ["本月进场人数", "本月退场人数", "已发放工资人数"];
            let data = [
                this.dataobj.statistics.enter,
                this.dataobj.statistics.out,
                this.dataobj.statistics.paid,
            ];
            let totlelist = data.reduce((cur, pre) => {
                cur.push(Math.max.apply(null, data) + 200);
                return cur;
            }, []);
            let obj = {
                grid: {
                    left: "35%",
                    top: "30%",
                    bottom: "10%",
                    right: "15%",
                },
                tooltip: {
                    trigger: "axis",
                    axisPointer: {
                        type: "none",
                    },
                    formatter: function (params) {
                        return (
                            params[0].name +
                            "<br/>" +
                            "<span style='display:inline-block;margin-right:5px;border-radius:10px;width:9px;height:9px'></span>" +
                            "数量" +
                            " : " +
                            Number(params[0].value).toLocaleString() +
                            " <br/>"
                        );
                    },
                },
                xAxis: {
                    show: false,
                    type: "value",
                },
                yAxis: [
                    {
                        type: "category",
                        inverse: true,
                        axisLabel: {
                            align: "left",
                            show: true,
                            padding: [0, 0, 0, -140],
                            textStyle: {
                                color: "#fff",
                                // fontSize: fontChart(5.1),
                                fontSize: 15.5,
                            },
                        },
                        splitLine: {
                            show: false,
                        },
                        axisTick: {
                            show: false,
                        },
                        axisLine: {
                            show: false,
                        },
                        data: xdata,
                    },
                    {
                        type: "category",
                        inverse: true,
                        axisTick: "none",
                        axisLine: "none",
                        offset: 2,
                        show: true,
                        axisLabel: {
                            textStyle: {
                                color: "#169BEC",
                                // fontSize: fontChart(5.1),
                                fontSize: 18,
                            },
                            formatter: function (value) {
                                return value.toLocaleString() + "人";
                            },
                        },
                        data: data,
                    },
                ],
                series: [
                    {
                        name: "单位",
                        type: "bar",
                        zlevel: 1,
                        itemStyle: {
                            normal: {
                                barBorderRadius: 0,
                                color: (params) => {
                                    let colors = [
                                        new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                            {
                                                offset: 0,
                                                color: "rgba(12,137,202)",
                                            },
                                            {
                                                offset: 1,
                                                color: "rgba(107,255,242)",
                                            },
                                        ]),
                                        new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                            {
                                                offset: 0,
                                                color: "rgba(118, 99, 72)",
                                            },
                                            {
                                                offset: 1,
                                                color: "rgba(240, 175, 69)",
                                            },
                                        ]),
                                        new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                            {
                                                offset: 0,
                                                color: "rgba(12,137,202)",
                                            },
                                            {
                                                offset: 1,
                                                color: "rgba(107,255,242)",
                                            },
                                        ]),
                                    ];
                                    return colors[params.dataIndex];
                                },
                            },
                        },
                        barWidth: 12,
                        data: data,
                    },
                    {
                        name: "背景",
                        type: "bar",
                        barWidth: 12,
                        barGap: "-100%",
                        data: totlelist,
                        itemStyle: {
                            normal: {
                                color: "rgba(27,52,93,1)",
                                barBorderRadius: 0,
                            },
                        },
                    },
                ],
            };
            defaultAlarm_E.setOption(obj, true);
        },
        renderreliability() {
            let defaultAlarm_E = null;
            echarts.init(this.$refs["reliability"]).dispose();
            defaultAlarm_E = echarts.init(this.$refs["reliability"]);
            var data = [...this.dataobj.attendance];
            let xData = [];
            let i = data.length;
            while (i >= 0) {
                xData.push(
                    dayjs(new Date().getTime() - i * 24 * 3600 * 1000).format("MM-DD")
                );
                i--;
            }
            xData.shift();
            let zxdata = data.reduce((cur, pre) => {
                cur.push(Number(pre));
                return cur;
            }, []);
            const obj = {
                title: {
                    text: data.length == 0 ? "暂无项目" : "近七日考勤情况",
                    left: "center",
                    top: data.length == 0 ? "center" : "10%",
                    textStyle: {
                        color: "#fff",
                        fontSize: 15,
                        fontWeight: "normal",
                    },
                },
                tooltip: {
                    trigger: "axis",
                    axisPointer: {
                        type: "shadow",
                        shadowStyle: {
                            color: "#19A7F9",
                            opacity: 0.5,
                        },
                        label: {
                            show: true,
                        },
                    },
                    formatter(params) {
                        var data = "";
                        for (var i = 0; i < params.length; i++) {
                            data += params[i].axisValue + ":  " + params[i].value + "<br/>";
                        }
                        return data;
                    },
                },
                grid: {
                    borderWidth: 0,
                    top: "20%",
                    bottom: "10%",
                    left: "10%",
                    right: "5%",
                    textStyle: {
                        color: "#fff",
                    },
                },
                xAxis: [
                    {
                        type: "category",
                        axisLine: {
                            lineStyle: {
                                color: "#003271",
                            },
                        },
                        splitLine: {
                            show: false,
                            lineStyle: {
                                color: "rgb(32, 46, 113)",
                                opacity: 2,
                            },
                        },
                        axisTick: {
                            show: false,
                        },
                        splitArea: {
                            show: false,
                        },
                        axisLabel: {
                            inside: false,
                            textStyle: {
                                color: "#fff",
                                fontWeight: "normal",
                                // fontSize: fontChart(5.1),
                                fontSize: 15.5,
                            },
                        },
                        data: xData,
                    },
                ],
                yAxis: {
                    type: "value",
                    show: false,
                    axisTick: {
                        show: false,
                    },
                    min: 0,
                    max: data.length == 0 ? 1 : Math.max.apply(null, data) + 20,
                    axisLine: {
                        show: false,
                        lineStyle: {
                            color: "#32346c",
                        },
                    },
                    splitLine: {
                        show: false,
                        lineStyle: {
                            color: "rgb(32, 46, 113)",
                        },
                    },
                    axisLabel: {
                        textStyle: {
                            color: "#fff",
                            fontWeight: "normal",
                            // fontSize: fontChart(5.1),
                            fontSize: 15.5,
                        },
                        formatter: "{value}",
                    },
                },
                series: [
                    {
                        type: "bar",
                        barWidth: 60,
                        backgroundStyle: {
                            color: "rgba(13, 27, 81, 0.9)",
                            opacity: 0.5,
                        },
                        data: data,
                        showBackground: true,
                        itemStyle: {
                            type: "dotted",
                            normal: {
                                // color: "#0096FF",
                                color: "rgba(13, 27, 81, 0.9)",
                                borderColor: "rgba(13, 27, 81, 0.9)",
                                opacity: 0.1,
                                label: {
                                    show: false,
                                    position: "insideBottom",
                                    textStyle: {
                                        color: "#FFFFFF",
                                        fontSize: fontChart(5.1),
                                        fontWeight: "600",
                                    },
                                },
                            },
                        },
                    },
                    {
                        name: "总数",
                        type: "line",
                        stack: "总量",
                        smooth: false, //是否平滑
                        showAllSymbol: true,
                        symbol: "circle",
                        areaStyle: {
                            normal: {
                                color: new echarts.graphic.LinearGradient(
                                    0,
                                    0,
                                    0,
                                    1,
                                    [
                                        {
                                            offset: 0,
                                            color: "rgba(4, 146, 255, .8)", // 0% 处的颜色
                                        },
                                        {
                                            offset: 1,
                                            color: "rgba(4, 146, 255, 0)", // 100% 处的颜色
                                        },
                                    ],
                                    false
                                ),
                            },
                        },
                        symbolSize: 10,
                        lineStyle: {
                            normal: {
                                color: "#48B3FF",
                            },
                        },
                        label: {
                            show: true,
                            position: "top",
                            textStyle: {
                                color: "#48B3FF",
                            },
                        },
                        itemStyle: {
                            color: "#04E4FF",
                            borderColor: "#48B3FF",
                            borderWidth: 2,
                        },
                        tooltip: {
                            show: false,
                        },
                        data: zxdata,
                    },
                ],
            };
            defaultAlarm_E.setOption(obj, true);
        },
        getfemaleUsers(value1, value2) {
            let that = this
            var imglist = {
                womenbg: require("@/views/monitoring/images/womenbg.png"),
                womenac: require("@/views/monitoring/images/womenac.png"),
                manac: require("@/views/monitoring/images/manac.png"),
                manbg: require("@/views/monitoring/images/manbg.png"),
            };
            echarts.init(this.$refs["femaleUsers"]).dispose();
            let defaultAlarm_E = echarts.init(this.$refs["femaleUsers"]);
            let totle = this.personcount || 2;
            let obj = {
                grid: {
                    left: "5%",
                    top: "20%",
                    bottom: "1%",
                    right: "32%",
                },
                tooltip: {
                    show: false,
                },
                xAxis: {
                    splitLine: {
                        show: false,
                    },
                    axisLine: {
                        show: false,
                    },

                    axisTick: {
                        show: false,
                    },
                },
                yAxis: [
                    {
                        type: "category",
                        inverse: false,
                        axisLine: {
                            show: false,
                        },
                        axisTick: {
                            show: false,
                        },
                        splitLine: {
                            show: false,
                            lineStyle: {
                                type: "dashed",
                                color: "#3e86dd",
                            },
                        },
                        axisLabel: {
                            show: false,
                            textStyle: {
                                color: "#fff",
                                fontSize: fontChart(5.1),
                            },
                        },
                    },
                ],
                series: [
                    {
                        tooltip: {
                            show: false,
                        },
                        silent: true,
                        type: "pictorialBar",
                        symbolSize: ["20", "40"],
                        symbolRepeat: "fixed",
                        symbolMargin: "55%",
                        data: [
                            {
                                value: totle,
                                symbol: "image://" + imglist.womenbg,
                            },
                            {
                                value: totle,
                                symbol: "image://" + imglist.manbg,
                            },
                        ],
                    },
                    {
                        type: "pictorialBar",
                        symbolRepeat: "fixed",
                        symbolSize: ["20", "40"],
                        symbolClip: true,
                        itemStyle: {
                            normal: {
                                opacity: 1,
                            },
                        },
                        tooltip: {
                            show: true,
                        },
                        symbolMargin: "55%",
                        data: [
                            {
                                name: "女",
                                value: value1,
                                // value: 5,
                                borderWidth: 20,
                                label: {
                                    normal: {
                                        show: true,
                                        formatter: function (obj) {
                                            let value = obj.data.value;
                                            let bfb = getpercentage(value, totle)
                                            let str = that.islineFeed ? `${bfb}\n${value}人` : `${bfb} ${value}人`
                                            return str
                                        },
                                        textStyle: {
                                            color: "#FF655F",
                                            // fontSize: fontChart(5.1),
                                            fontSize: 18,
                                        },
                                        position: "right",

                                        offset: [20, 0],
                                    },
                                },
                                symbol: "image://" + imglist.womenac,
                            },
                            {
                                name: "男",
                                value: value2,
                                // value: 3,
                                label: {
                                    normal: {
                                        show: true,
                                        formatter: function (obj) {
                                            let value = obj.data.value;
                                            let bfb = getpercentage(value, totle)
                                            let str = that.islineFeed ? `${bfb}\n${value}人` : `${bfb} ${value}人`
                                            return str
                                        },
                                        textStyle: {
                                            color: "#18fcff",
                                            fontSize: 18,
                                        },
                                        position: "right",
                                        offset: [20, 0],
                                    },
                                },
                                symbol: "image://" + imglist.manac,
                            },
                        ],
                    },
                ],
            };
            defaultAlarm_E.setOption(obj, true);
        },
        getpersonage(objtime, ref) {
            let that = this
            let dataList = [];
            let totle = this.personcount;
            Object.keys(objtime).map((key, index) => {
                let colorslist = [
                    "#3165FE",
                    "#14C2FF",
                    "#37DB69",
                    "#F8B141",
                    "#FF655F",
                ];
                let name = key;
                let value = objtime[key];
                let scales = getpercentage(value, totle)
                let itemStyle = {
                    normal: {
                        color: colorslist[index],
                    },
                };
                dataList.push({ value, scales, show: true, name, itemStyle });
            });
            echarts.init(this.$refs[ref]).dispose();
            let defaultAlarm_E = echarts.init(this.$refs[ref]);
            let legend = {
                type: "plain",
                orient: "vertical",
                left: "42%",
                right: "10%",
                icon: "circle",
                top: "center",
                itemGap: 16,
                textStyle: {
                    color: "#000",
                    rich: {
                        name: {
                            verticalAlign: "right",
                            align: "left",
                            width: 99,
                            // fontSize: fontChart(5.1),
                            fontSize: 15.5,
                            color: "#fff",
                        },
                        value: {
                            align: "left",
                            width: 90,
                            // fontSize: fontChart(5.1),
                            fontSize: 15.5,
                            color: "#fff",
                        },
                        scale: {
                            // fontSize: fontChart(5.1),
                            fontSize: 15.5,
                            width: that.islineFeed ? 120 : 80,
                            color: "#fff",
                            align: "left",
                        },
                    },
                },
                data: dataList.map((item) => {
                    if (item.show) {
                        return item.name;
                    }
                }),
                formatter: function (name) {
                    if (dataList && dataList.length) {
                        for (var i = 0; i < dataList.length; i++) {
                            if (name === dataList[i].name) {
                                return (
                                    "{name| " +
                                    name +
                                    "} " +
                                    "{scale|" +
                                    dataList[i].scales +
                                    "}" +
                                    "{value| " +
                                    dataList[i].value +
                                    "}"
                                );
                            }
                        }
                    }
                },
            };

            let obj = {
                title: {
                    text: `{b|总人数(人)}\n{a|${totle}}`,
                    textAlign: "center",
                    textStyle: {
                        rich: {
                            a: {
                                fontSize: 15.5,
                                color: "#fff",
                            },
                            b: {
                                fontSize: 15.5,
                                color: "#fff",
                                padding: 3,
                            },
                        },
                    },
                    left: "24%",
                    top: "47%",
                },
                legend,
                tooltip: {
                    trigger: "item",
                },
                series: [
                    {
                        itemStyle: {
                            normal: {
                                show: true,
                            },
                        },
                        type: "pie",
                        radius: ["40%", "60%"],
                        center: ["25%", "55%"],
                        label: {
                            normal: {
                                show: false,
                            },
                        },
                        data: dataList,
                    },
                    {
                        itemStyle: {
                            normal: {
                                color: "rgba(0,177,242, 0.3)",
                            },
                        },
                        type: "pie",
                        hoverAnimation: false,
                        radius: ["35%", "65%"],
                        center: ["25%", "55%"],
                        label: {
                            normal: {
                                show: false,
                            },
                        },
                        data: [
                            {
                                value: 1,
                            },
                        ],
                        z: -1,
                    },
                ],
            };

            defaultAlarm_E.setOption(obj, true);
        },
        getprojectandname() {
            echarts.init(this.$refs["distribution"]).dispose();
            let defaultAlarm_E = echarts.init(this.$refs["distribution"]);
            let totlelist = { ...this.dataobj["provinceTimesto"] };
            let prolist = { ...this.dataobj["provinceTimes"] };
            let xdata = [];
            let data = [];
            let leftdata = [];
            Object.keys(totlelist).map((key) => {
                xdata.push(key);
                data.push(totlelist[key]);
            });
            xdata.map((item, index) => {
                Object.keys(prolist).map((key) => {
                    if (item == key) {
                        leftdata[index] = prolist[key];
                    }
                });
            });
            for (let io = 0; io < leftdata.length; io++) {
                leftdata[io] = leftdata[io] || 0;
            }
            let obj = {
                grid: {
                    top: "30%",
                    left: "5%",
                    right: "5%",
                    bottom: "12%",
                    containLabel: true,
                },
                tooltip: {
                    trigger: "axis",
                    axisPointer: {
                        type: "shadow",
                        label: {
                            show: true,
                        },
                    },
                    formatter(params) {
                        var data = "";
                        for (var i = 0; i < params.length; i++) {
                            if (params[i].seriesName == "随访率") {
                                data += params[i].seriesName + ":  " + params[i].value + "%";
                            } else {
                                data +=
                                    params[i].seriesName + ":  " + params[i].value + "<br/>";
                            }
                        }
                        return data;
                    },
                },
                legend: {
                    right: "5%",
                    top: "5%",
                    textStyle: {
                        color: "#fff",
                    },
                    icon: "rect",
                    itemGap: 15,
                    itemWidth: 15,
                    itemHeight: 15,
                    itemStyle: {
                        borderWidth: 0,
                    },
                },
                xAxis: {
                    type: "category",
                    data: xdata,
                    axisLine: {
                        show: true,
                        lineStyle: {
                            width: 2,
                            color: "#1d3b7e",
                        },
                    },
                    axisTick: {
                        show: false,
                    },
                    axisLabel: {
                        // fontSize: fontChart(5.1),
                        fontSize: 15.5,
                        color: "#fff",
                        show: true,
                    },
                },
                yAxis: [
                    {
                        splitLine: {
                            //控制刻度横线的显示
                            show: false,
                        },
                        nameTextStyle: {
                            color: "#fff",
                            show: false,
                        },
                        type: "value",
                        splitNumber: 5,
                        min: 0,
                        max: data.length == 0 ? 1 : Math.max.apply(null, data) + 1,
                        axisTick: {
                            show: false, //不显示坐标轴刻度
                        },
                        axisLabel: {
                            formatter: "{value}",
                            show: true,
                            textStyle: {
                                color: "#fff",
                                // fontSize: fontChart(5.1),
                                fontSize: 15.5,
                            },
                        },
                        axisLine: {
                            // Y轴线的颜色、和轴线的宽度
                            lineStyle: {
                                color: "#1d3b7e",
                                width: 2,
                            },
                        },
                    },
                    {
                        splitLine: {
                            show: false,
                        },
                        axisTick: {
                            show: false, //不显示坐标轴刻度
                        },
                        type: "value",
                        max: leftdata.length == 0 ? 1 : Math.max.apply(null, leftdata) + 1,
                        splitNumber: 5,
                        min: 0,
                        axisLabel: {
                            formatter: "{value}",
                            show: true,
                            textStyle: {
                                color: "#fff",
                                // fontSize: fontChart(5.1),
                                fontSize: 15.5,
                            },
                        },
                        axisLine: {
                            lineStyle: {
                                color: "#1d3b7e",
                                width: 2,
                            },
                        },
                    },
                ],
                dataZoom: [
                    // {
                    //   type: "slider",
                    //   show: true, //隐藏或显示（true）组件
                    //   backgroundColor: "rgba(0, 27, 95,.5)", // 组件的背景颜色。
                    //   fillerColor: "rgb(40, 89, 176)", // 选中范围的填充颜色。
                    //   borderColor: "rgba(0, 27, 95,.5)", // 边框颜色
                    //   showDetail: false, //是否显示detail，即拖拽时候显示详细数值信息
                    //   startValue: 0, // 数据窗口范围的起始数值
                    //   endValue: 4, // 数据窗口范围的结束数值（一页显示多少条数据）
                    //   yAxisIndex: [0, 1], //控制哪个轴，如果是 number 表示控制一个轴，如果是 Array 表示控制多个轴。此处控制第二根轴
                    //   filterMode: "empty",
                    //   width: 8, //滚动条高度
                    //   height: "80%", //滚动条显示位置
                    //   right: 3, // 距离右边
                    //   handleSize: 0, //控制手柄的尺寸
                    //   zoomLoxk: true, // 是否锁定选择区域（或叫做数据窗口）的大小
                    //   top: "middle",
                    // },
                    // {
                    //   type: "inside",
                    //   yAxisIndex: [0, 1], //控制哪个轴，如果是 number 表示控制一个轴，如果是 Array 表示控制多个轴。此处控制第二根轴
                    //   zoomOnMouseWheel: false, //滚轮是否触发缩放
                    //   moveOnMouseMove: true, //鼠标移动能否触发平移
                    //   moveOnMouseWheel: true, //鼠标滚轮能否触发平移
                    // },
                    {
                        xAxisIndex: 0, //这里是从X轴的0刻度开始
                        show: true, //是否显示滑动条，不影响使用
                        type: "slider", // 这个 dataZoom 组件是 slider 型 dataZoom 组件
                        startValue: 0, // 从头开始。
                        endValue: 4, // 一次性展示6个
                        height: 8, //组件高度
                        bottom: 10,
                        backgroundColor: "rgba(0, 27, 95,.5)", // 组件的背景颜色。
                        fillerColor: "rgb(40, 89, 176)", // 选中范围的填充颜色。
                        borderColor: "rgba(0, 27, 95,.5)", // 边框颜色
                        zoomLock: true,
                        showDataShadow: false, //是否显示数据阴影 默认auto

                        showDetail: false, //即拖拽时候是否显示详细数值信息 默认true
                        realtime: true, //是否实时更新
                        filterMode: "filter",
                        moveHandleSize: 20,
                        moveOnMouseMove: true,
                        maxValueSpan: 7,
                        minValueSpan: 7,
                        moveHandleSize: 0,
                        brushSelect: false, //刷选功能，设为false可以防止拖动条长度改变 ************（这是一个坑）
                    },
                ],
                series: [
                    {
                        name: "项目数(个)",
                        type: "bar",
                        yAxisIndex: 0,
                        barWidth: 20,
                        data: data,
                        itemStyle: {
                            //双Y轴A柱的柱体颜色
                            normal: {
                                color: new echarts.graphic.LinearGradient(
                                    0,
                                    0,
                                    0,
                                    1,
                                    [
                                        {
                                            offset: 0,
                                            color: "rgba(62, 176, 250, 1)", // 0% 处的颜色
                                        },
                                        {
                                            offset: 0.98,
                                            color: "rgba(62, 176, 250, 0)", // 100% 处的颜色
                                        },
                                    ],
                                    false
                                ),
                                barBorderRadius: [24, 4, 30, 0],
                                barWidth: "20px",
                                label: {
                                    show: true, //开启显示
                                    position: "top", //在上方显示
                                    textStyle: {
                                        //数值样式
                                        color: "#fff",
                                        fontSize: fontChart(5.1),
                                    },
                                },
                            },
                        },
                    },
                    {
                        name: "人数(人)",
                        type: "bar",
                        barWidth: 20,
                        yAxisIndex: 1,
                        data: leftdata,
                        itemStyle: {
                            normal: {
                                color: new echarts.graphic.LinearGradient(
                                    0,
                                    0,
                                    0,
                                    1,
                                    [
                                        {
                                            offset: 0,
                                            color: "rgba(74, 89, 252, 1)", // 0% 处的颜色
                                        },
                                        {
                                            offset: 0.98,
                                            color: "rgba(74, 89, 252, 0)", // 100% 处的颜色
                                        },
                                    ],
                                    false
                                ),
                                barBorderRadius: [24, 4, 30, 0],
                                label: {
                                    show: true, //开启显示
                                    position: "top", //在上方显示
                                    textStyle: {
                                        color: "#fff",
                                        // fontSize: fontChart(5.1),
                                        fontSize: 15.5,
                                    },
                                },
                            },
                        },
                    },
                ],
            };
            defaultAlarm_E.setOption(obj, true);
        },
        getmap() {
            let provinceTimesto = this.dataobj.provinceTimesto
            let dataList = []
            Object.keys(provinceTimesto).map(key => {
                let cuskey = JSON.parse(JSON.stringify(key))
                cuskey = cuskey.replace(/省|市|自治区/g, "")
                dataList.push({
                    name: cuskey,
                    value: provinceTimesto[key]
                })
            })
            console.log(dataList)
            echarts.init(this.$refs["map"]).dispose();
            let defaultAlarm_E = echarts.init(this.$refs["map"]);
            let obj = {
                title: {
                    show: false,
                },
                tooltip: {
                    triggerOn: "mousemove",
                    formatter: function (e, t, n) {
                        let value = isNaN(e.value) ? 0 : e.value;
                        return e.seriesName + "<br />" + e.name + "：" + value;
                    },
                },
                // 热力地图
                visualMap: {
                    min: 0,
                    max: 10000000,
                    right: "10%",
                    bottom: "15%",
                    show: true,
                    itemGap: 50,
                    selectedMode: false,
                    orient: "vertical",
                    textStyle: {
                        color: "#fff",
                    },
                    pieces: [
                        {
                            gt: 1000,
                            label: "人数>1000人",
                            color: "#FF655F",
                        },
                        {
                            gt: 500,
                            lte: 1000,
                            label: "1000>人数>500人",
                            color: "#F8B141",
                        },
                        {
                            gt: 100,
                            lte: 500,
                            label: "500>人数>100人",
                            color: "#37DB69",
                        },
                        {
                            gte: 0,
                            lte: 100, // [0,100]
                            label: "100>人数>0人",
                            color: "#25b1f3",
                        },
                    ],
                },
                geo: [
                    {
                        // 地理坐标系组件
                        map: "china",
                        roam: false, // 可以缩放和平移
                        aspectScale: 0.8, // 比例
                        layoutCenter: ["39%", "50%"], // position位置
                        layoutSize: 450, // 地图大小，保证了不超过 370x370 的区域
                        label: {
                            normal: {
                                show: false, //显示省份标签
                            },
                            emphasis: {
                                show: false, //对应的鼠标悬浮效果
                            },
                        },
                        regions: [
                            {
                                name: "南海诸岛",
                                itemStyle: {
                                    // 隐藏地图
                                    normal: {
                                        opacity: 0, // 为 0 时不绘制该图形
                                    },
                                },
                                label: {
                                    show: false, // 隐藏文字
                                },
                            },
                        ],
                        itemStyle: {
                            // 默认区域样式
                            label: {
                                show: false,
                            },
                            normal: {
                                // 区域背景透明
                                areaColor: "#3141b1",
                                borderColor: "#17157e",
                                borderWidth: 1,
                            },
                            // 高亮区域样式
                            emphasis: {
                                color: "#2d60b9",
                            },
                        },
                    },
                ],
                series: [
                    {
                        name: "地点",
                        data: dataList,
                        type: "map",
                        map: "china",
                        coordinateSystem: "geo",
                        zoom: 1.2,
                        aspectScale: 0.75,
                        geoIndex: 0,
                        selectedMode: "single",
                    },
                ],
            };
            defaultAlarm_E.setOption(obj, true);
        },
    }
}
